#include <iostream>
#include <string>
#include <vector>
#include <curl/curl.h>

static size_t WriteCallbackLibcurl(void* contents, size_t size, size_t nmemb, void* userp) {
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

void checkUpdateWithLibcurl() {
    CURL* curl;
    CURLcode res;
    std::string readBuffer;
    std::string ftpUrl = "ftp://your_ftp_server.com/path/to/latest_version.txt";
    std::string userPwd = "your_username:your_password";

    curl_global_init(CURL_GLOBAL_ALL);
    curl = curl_easy_init();
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, ftpUrl.c_str());
        curl_easy_setopt(curl, CURLOPT_USERPWD, userPwd.c_str());
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallbackLibcurl);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
        curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 1L);
        
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
        } else {
            std::cout << "Fetched version info (libcurl):\n" << readBuffer << std::endl;
        }
        curl_easy_cleanup(curl);
    }
    curl_global_cleanup();
}